package com.ltkj.shop.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.shop.domain.ShopGoodsCenters;
import com.ltkj.shop.service.IShopGoodsCentersService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 商品自提点Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "商品自提点")
@RestController
@RequestMapping("/goodsCenters")
public class ShopGoodsCentersController extends BaseController
{
    @Autowired
    private IShopGoodsCentersService shopGoodsCentersService;

    /**
     * 查询商品自提点列表
     */
    @ApiOperation("查询商品自提点列表")
    @RequiresPermissions("shop:goodsCenters:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopGoodsCenters shopGoodsCenters)
    {
        startPage();
        List<ShopGoodsCenters> list = shopGoodsCentersService.selectShopGoodsCentersList(shopGoodsCenters);
        return getDataTable(list);
    }

    /**
     * 导出商品自提点列表
     */
    @ApiOperation("导出商品自提点列表")
    @RequiresPermissions("shop:goodsCenters:export")
    @Log(title = "商品自提点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopGoodsCenters shopGoodsCenters)
    {
        List<ShopGoodsCenters> list = shopGoodsCentersService.selectShopGoodsCentersList(shopGoodsCenters);
        ExcelUtil<ShopGoodsCenters> util = new ExcelUtil<ShopGoodsCenters>(ShopGoodsCenters.class);
        util.exportExcel(response, list, "商品自提点数据");
    }

    /**
     * 获取商品自提点详细信息
     */
    @ApiOperation("获取商品自提点详细信息")
    @RequiresPermissions("shop:goodsCenters:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopGoodsCentersService.selectShopGoodsCentersById(id));
    }

    /**
     * 新增商品自提点
     */
    @ApiOperation("新增商品自提点")
    @RequiresPermissions("shop:goodsCenters:add")
    @Log(title = "商品自提点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopGoodsCenters shopGoodsCenters)
    {
        return toAjax(shopGoodsCentersService.insertShopGoodsCenters(shopGoodsCenters));
    }

    /**
     * 修改商品自提点
     */
    @ApiOperation("修改商品自提点")
    @RequiresPermissions("shop:goodsCenters:edit")
    @Log(title = "商品自提点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopGoodsCenters shopGoodsCenters)
    {
        return toAjax(shopGoodsCentersService.updateShopGoodsCenters(shopGoodsCenters));
    }

    /**
     * 删除商品自提点
     */
    @ApiOperation("删除商品自提点")
    @RequiresPermissions("shop:goodsCenters:remove")
    @Log(title = "商品自提点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopGoodsCentersService.deleteShopGoodsCentersByIds(ids));
    }
}
